1. Field of the Invention
The invention relates in general to a method and a system for detecting and recovering a failure command, and more particularly to a method and a system for detecting and recovering a failure command for detecting several commands of a native command queuing (NCQ).
2. Description of the Related Art
Storage controller allows many un-executed commands to be executed on a disk simultaneously, and such technology is referred to as native command queuing (NCQ) technology. An NCQ can resort the commands of the disk to optimize the workloads of the disk and increase the accessing efficiency of the disk.
Referring to FIG. 1A and FIG. 1B, FIG. 1A is a perspective of a conventional NCQ system. FIG. 1B is a perspective of another conventional NCQ system. As indicated in FIG. 1A, the conventional NCQ 110a includes a first command 101 and a second command 102, wherein the first command 101 and the second command 102 are waiting to be executed on the disk 100. In the conventional NCQ 110a, if the first command 101 accesses a bad sector of the disk 100 to cause the request time of the commands to be longer than the waiting time, then all the commands of the NCQ 110a will be cancelled. That is, the first command 101 and the second command 102 will not be executed successfully. However, if the first command 101 sends an execution request again and is prioritized in the NCQ 110b with the third command 103 as indicated in FIG. 1B, all the commands of the NCQ 110b will be cancelled to cause both the first command 101 and the third command 103 to fail because the first command 101 still accesses the bad sector of the disk 100.
For the conventional NCQ 110a and 110b, as the first command 101 accesses the bad sector, the second command 102 and the third command 103 can not be executed successfully. Thus the system execution ability is deteriorated. Besides, if the first command 101 again sends an execution request, there will be more commands that can not be executed successfully, hence the reliability and efficiency of the system is decreased.